package cn.test.app.a.fallback;

import cn.test.app.a.api.OrderApi;
import cn.test.app.a.domain.Ord;
import cn.test.app.a.vo.OrdVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author: float 2022/11/3 09:56
 */
@Lazy
@Component
public class OrderFallBackFactory implements FallbackFactory<OrderApi> {

    public final Logger log = LoggerFactory.getLogger(this.getClass());

    @Override
    public OrderApi create(Throwable cause) {
        log.error(cause.toString());
        log.error("echoFallBackFactory:", cause);
        return new OrderApi() {

            @Override
            public void add(Ord ord) {
                System.err.println("fallBack add logic");
            }

            @Override
            public Boolean del(Long id) {
                System.err.println("fallBack del logic");
                return null;
            }

            @Override
            public Boolean edit(Ord ord) {
                System.err.println("fallBack edit logic");
                return null;
            }

            @Override
            public List<Ord> list(OrdVo ordVo) {
                System.err.println("fallBack list logic");
                return null;
            }

            @Override
            public List<Ord> ordList() {
                return null;
            }
        };
    }
}
